package com.jinmdz.app.dao.dao;


import com.jinmdz.app.dao.dao.provider.SystemUserProvider;
import com.jinmdz.app.dao.model.user.RoleUserViewItem;
import com.jinmdz.app.dao.model.user.SystemUserItem;
import com.jinmdz.app.dao.model.user.SystemUserLoginItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户Dao
 *
 * @author LiCongLu
 * @date 2019-12-30 11:20
 */
public interface SystemUserDao {
    /**
     * 通过username查询登录帐号信息
     *
     * @param username 登录帐号
     * @return SystemUserItem
     * @author LiCongLu
     * @date 2019-12-30 11:23
     */
    @Select(" select id,login_username,login_password,login_secret_key,job_no,full_name,disable_state,version " +
            " from system_user where login_username = #{username} and as_login=1 and deleted=0 limit 1 ")
    SystemUserLoginItem getSystemUserLoginByUsername(@Param("username") String username);

    /**
     * 按照用户组编码查询用户
     *
     * @param codeList 分组编码
     * @return
     * @author LiCongLu
     * @date 2020-01-16 09:26
     */
    @SelectProvider(type = SystemUserProvider.class, method = "listRoleUserViewByCodes")
    ArrayList<RoleUserViewItem> listRoleUserViewByCodes(@Param("codeList") ArrayList<String> codeList);

    /**
     * 按照主键获取帐号信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-02-20 17:25
     */
    @Select(" select id,login_username,login_password,login_secret_key,job_no,full_name,user_gender_code,mobile_phone,other_phone" +
            " ,address,company_id,department_id,disable_state,as_login,ic_card_code,sort,remark,version " +
            " from system_user where id = #{id} limit 1 ")
    SystemUserItem getSystemUserById(@Param("id") Integer id);


    /**
     * 获得用户信息
     *
     * @param userIds
     * @return
     * @author ZhangLiRui
     * @date 2020/6/15 15:07
     */
    @SelectProvider(type = SystemUserProvider.class, method = "listSystemUserByIds")
    ArrayList<SystemUserItem> listSystemUserByIds(@Param("userIds") List<Integer> userIds);

    /**
     * 按照员工编号帐号信息
     *
     * @param jobNo 员工编号
     * @return
     * @author LiCongLu
     * @date 2020-02-20 17:25
     */
    @Select(" select id,login_username,login_password,login_secret_key,job_no,full_name,user_gender_code,mobile_phone,other_phone" +
            " ,address,company_id,department_id,disable_state,as_login,ic_card_code,sort,remark,version " +
            " from system_user where job_no = #{jobNo} and deleted = 0 and disable_state = 0 limit 1 ")
    SystemUserItem getSystemUserByJobNo(@Param("jobNo") String jobNo);
}
